﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AspZone.Commerce.Model;

namespace AspZone.Commerce.Web.Helpers
{
    public static class CatalogHelper
    {
        public static string ProductThumbnailImage(this HtmlHelper helper, Product p)
        {
            if (p.Images != null && p.Images.Count > 0)
            {
                string basePath = VirtualPathUtility.ToAbsolute("~/Content/ProductImages");
                string fullPath = string.Format("{0}/{1}", basePath, p.Images[0].ThumbnailPath);
                return helper.Image(fullPath);
            }
            else
            {
                return null;
            }
        }
    }
}
